define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {

        index: function () {
            Controller.api.bindevent();
        },
        clientlog: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/index',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/clientlogajax',
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'nickname', title: __('销售'),  operate: false},
                        {field: 'name', title: __('店铺'),  operate: false},
                        {field: 'title', title: __('访问类型'), operate: false},
                        {field: 'desc', title: __('说明'), operate: false},
                        {field: 'typesv', title: __('说明'), operate: false},

                        {field: 'address', title: __('地址'), operate: false},
                        {field: 'time', title: __('访问时间'), operate: false}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        nosee: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/index',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/noseeajax',
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'name', title: __('店铺'),  operate: false},
                        {field: 'text', title: __('区域'), operate: false},
                        {field: 'address', title: __('地址'), operate: false},
                        {field: 'time', title: __('访问时间'), operate: false}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        hour: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/hourajax',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/hourajax',
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                method:'post',

                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'text', title: __('区域'), operate: false},
                        {field: 'nickname', title: __('负责人'),  operate: false},
                        {field: 'mobile', title: __('联系人'), operate: false},
                        {field: 'hour', title: __('工作时间'), operate: false,sortable:true}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },


        users: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/hourajax',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/usersajax',
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                pagination: false,
                fixedRightNumber: 1,
                searchFormTemplate: 'customformtpl',
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'nickname', title: __('销售'), operate: false},
                        {field: 'text', title: __('区域'), operate: false},
                        {field: 'name', title: __('店铺'),  operate: false},
                        {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'lng', title: __('Lng'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'lat', title: __('Lat'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'types', title: __('Types'), searchList: {"1":__('Types 1'),"0":__('Types 0')}, formatter: Table.api.formatter.normal},
                        // {field: 'quyu_id', title: __('Quyu_id')},
                        {field: 'c_name', title: __('C_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'c_sex', title: __('C_sex'), searchList: {"1":__('C_sex 1'),"0":__('C_sex 0')}, formatter: Table.api.formatter.normal},
                        {field: 'c_mobile', title: __('C_mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'c_wx', title: __('C_wx'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'types', title: __('类型'),  operate: false},
                        {field: 'ctypes', title: __('Ctypes'), searchList: {"1":__('Ctypes 1'),"2":__('Ctypes 2'),"3":__('Ctypes 3')}, formatter: Table.api.formatter.normal},
                        {field: 'time', title: __('时间'), operate: false,sortable:true}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        userb: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/hourajax',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/userbajax',
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                pagination: false,
                searchFormTemplate: 'customformtpl',
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'text', title: __('区域'), operate: false},
                        {field: 'name', title: __('店铺'),  operate: false},
                        {field: 'address', title: __('地址'), operate: false},
                        {field: 'types', title: __('类型'),  operate: false},
                        {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lng', title: __('Lng'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lat', title: __('Lat'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'types', title: __('Types'), searchList: {"1":__('Types 1'),"0":__('Types 0')}, formatter: Table.api.formatter.normal},
                        // {field: 'quyu_id', title: __('Quyu_id')},
                        {field: 'c_name', title: __('C_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'c_sex', title: __('C_sex'), searchList: {"1":__('C_sex 1'),"0":__('C_sex 0')}, formatter: Table.api.formatter.normal},
                        {field: 'c_mobile', title: __('C_mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'c_wx', title: __('C_wx'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'time', title: __('时间'), operate: false,sortable:true}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        orders: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'chient/datas/hourajax',
                    add_url: 'chient/datas/add',
                    edit_url: '',
                    del_url: 'chient/datas/del',
                    multi_url: 'chient/datas/multi',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'chient/datas/ordersajax',
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                method:'post',
                pagination: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'text', title: __('区域'), operate: false},
                        {field: 'nickname', title: __('负责人'),  operate: false},
                        {field: 'count', title: __('拜访次数'),  operate: false},
                        {field: 'bili', title: __('比例'), operate: false,sortable:true}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },



        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
